home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Linux / Kubuntu 8.10 / kubuntu-8.10-desktop-i386.iso / casper / filesystem.squashfs / etc / init.d / networking < prev    next >
Text File  |  2008-06-23  |  3KB  |  128 lines

  1. #!/bin/sh -e
  2. ### BEGIN INIT INFO
  3. # Provides:          networking
  4. # Required-Start:    mountkernfs ifupdown $local_fs
  5. # Required-Stop:     ifupdown $local_fs
  6. # Default-Start:     S
  7. # Default-Stop:      0 6
  8. # Short-Description: Raise network interfaces.
  9. ### END INIT INFO
  10.  
  11. PATH="/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin"
  12.  
  13. # flag file to indicate that the network has been configured.
  14. # see LP: #44194 for details
  15. INIT_FLAG=/var/run/network/initialized
  16.  
  17. [ -x /sbin/ifup ] || exit 0
  18.  
  19. . /lib/lsb/init-functions
  20.  
  21. net_flag_up () {
  22.     touch $INIT_FLAG
  23. }
  24.  
  25. net_flag_down () {
  26.     rm -f $INIT_FLAG
  27. }
  28.  
  29. # helper function to set the usplash timeout. https://launchpad.net/bugs/21617
  30. usplash_timeout () {
  31.     TIMEOUT=$1
  32.     if [ -x /sbin/usplash_write ]; then
  33.         /sbin/usplash_write "TIMEOUT $TIMEOUT" || true
  34.     fi
  35. }
  36.  
  37. process_options() {
  38.     [ -e /etc/network/options ] || return 0
  39.     log_warning_msg "/etc/network/options still exists and it will be IGNORED! Read README.Debian of netbase."
  40. }
  41.  
  42. check_network_file_systems() {
  43.     [ -e /proc/mounts ] || return 0
  44.  
  45.     exec 9<&0 < /proc/mounts
  46.     while read DEV MTPT FSTYPE REST; do
  47.     case $DEV in
  48.     /dev/nbd*|/dev/nd[a-z]*|/dev/etherd/e*)
  49.         log_warning_msg "not deconfiguring network interfaces: network devices still mounted."
  50.         exit 0
  51.         ;;
  52.     esac
  53.     case $FSTYPE in
  54.     nfs|nfs4|smbfs|ncp|ncpfs|cifs|coda|ocfs2|gfs|pvfs|pvfs2)
  55.         log_warning_msg "not deconfiguring network interfaces: network file systems still mounted."
  56.         exit 0
  57.         ;;
  58.     esac
  59.     done
  60.     exec 0<&9 9<&-
  61. }
  62.  
  63. case "$1" in
  64. start)
  65.     process_options
  66.  
  67.     log_action_begin_msg "Configuring network interfaces"
  68.     usplash_timeout 120
  69.     if [ "$VERBOSE" != no ]; then
  70.         if ifup -a; then
  71.         log_action_end_msg $?
  72.         else
  73.         log_action_end_msg $?
  74.         fi
  75.     else
  76.         if ifup -a >/dev/null 2>&1; then
  77.         log_action_end_msg $?
  78.         else
  79.         log_action_end_msg $?
  80.         fi
  81.     fi
  82.     usplash_timeout 15
  83.     net_flag_up
  84.     ;;
  85.  
  86. stop)
  87.     check_network_file_systems
  88.  
  89.     log_action_begin_msg "Deconfiguring network interfaces"
  90.     if [ "$VERBOSE" != no ]; then
  91.         if ifdown -a --exclude=lo; then
  92.         log_action_end_msg $?
  93.         else
  94.         log_action_end_msg $?
  95.         fi
  96.     else
  97.         if ifdown -a --exclude=lo >/dev/null 2>/dev/null; then
  98.         log_action_end_msg $?
  99.         else
  100.         log_action_end_msg $?
  101.         fi
  102.         net_flag_down
  103.     fi
  104.     ;;
  105.  
  106. force-reload|restart)
  107.     process_options
  108.  
  109.     log_action_begin_msg "Reconfiguring network interfaces"
  110.     ifdown -a --exclude=lo || true
  111.     net_flag_down
  112.     if ifup -a --exclude=lo; then
  113.         net_flag_up
  114.         log_action_end_msg $?
  115.     else
  116.         log_action_end_msg $?
  117.     fi
  118.     ;;
  119.  
  120. *)
  121.     echo "Usage: /etc/init.d/networking {start|stop|restart|force-reload}"
  122.     exit 1
  123.     ;;
  124. esac
  125.  
  126. exit 0
  127.  
  128.